package com.huaxiafinance.management.controller;

import com.huaxiafinance.management.dto.request.QueryFranchiseeToBeInfoDto;
import com.huaxiafinance.management.service.PartnerGradeService;
import com.huaxiafinance.management.service.PartnerInfoService;
import com.huaxiafinance.management.util.MessageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;


/**
 * Created by Administrator on 2017/12/4.
 */
@Controller
@RequestMapping("/partnerInfo")
public class PartnerInfoController {

  private static final org.apache.log4j.Logger logger = org.apache.log4j.Logger
      .getLogger(PartnerInfoController.class);

  @Autowired
  private PartnerInfoService partnerInfoService;
  @Autowired
  private PartnerGradeService partnerGradeService;

  @RequestMapping(value = "/getFranchiseeToBe", produces = "application/json; charset=utf-8")

  public @ResponseBody
  String getFranchiseeToBe(@Valid @ModelAttribute("dto") QueryFranchiseeToBeInfoDto dto) {
    logger.info("接收到的请求参数为=====================" + dto);
    MessageResult result = partnerInfoService.getFranchiseeInfo(dto);
    logger.info("接收到的请求参数为=====================" + result.getAsJSON());
    return result.getAsJSON();
  }

  /**
   * 查询合伙人信息的查询页面
   *
   * @param dto 接手模糊查询的参数
   * @return String
   */
  @RequestMapping(value = "/queryResultByParam", produces = "application/json; charset=utf-8")
  public @ResponseBody
  String queryResultByParam(@ModelAttribute("dto") QueryFranchiseeToBeInfoDto dto) {
    MessageResult result = partnerInfoService.getAllResultByParam(dto);
    return result.getAsJSON();
  }
}
